

#import "PUHomeVC.h"
#import "PUHomeCell.h"
#import "PUCityListModel.h"
#import "PUFoodDetailsVC.h"
#import "PUData.h"
#import "PUModel.h"
//#import "XLTaoHuaRecordVC.h"

#import "PUPhoneLogin.h"
#import "PUHomeReusableView.h"
//#import "CPQSNMSVC.h"
#import "PUCategoryVC.h"
#import "PUFoodDetailsVC.h"
#import "PUFoodsModel.h"
#import "PUPerfectVC.h"
@interface PUHomeVC ()<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,XLHomeCellCellDelegate>
@property (nonatomic, strong) UICollectionView *collectView;
@property (nonatomic, retain) NSMutableArray *recommendData;
@property (nonatomic, retain) NSMutableArray *taohuaData;
@property (nonatomic, retain) NSMutableArray *taohuaData2;
@property (nonatomic, retain) NSMutableArray *arrayData;
@property (nonatomic) int page;
@property (nonatomic) int isFirstLoad;

@end

@implementation PUHomeVC


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor=[UIColor whiteColor];
    self.recommendData=[NSMutableArray array];
    self.taohuaData=[NSMutableArray array];
    self.taohuaData2=[NSMutableArray array];
    
    UIImageView *img=[[UIImageView alloc]init];
    img.backgroundColor=[UIColor whiteColor];
    img.image=[UIImage imageNamed:@"背景"];
    [self.view addSubview:img];
    
    [img mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view.mas_top).offset(0);
        make.left.equalTo(self.view.mas_left).offset(0);
        make.right.equalTo(self.view.mas_right).offset(0);
        make.bottom.equalTo(self.view.mas_bottom).offset(0);
       
    }];
    
    //加载collectionView视图
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;//垂直方向
    self.collectView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout];
    //          self.collectView.showsHorizontalScrollIndicator = NO;
    self.collectView.delegate = self;
    self.collectView.dataSource = self;
    self.collectView.backgroundColor =[UIColor clearColor];
    [self.view addSubview:self.collectView];
    
    //注册cell重用标识
    [self.collectView registerClass:[PUHomeCell class] forCellWithReuseIdentifier:@"XLHomeCell"];
    [self.collectView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
    [self.collectView registerClass:[PUHomeReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"CPHomeReusableView"];
    
    [self.collectView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view.mas_top).offset(STATUS_H_F);
        make.left.equalTo(self.view.mas_left).offset(0);
        make.right.equalTo(self.view.mas_right).offset(0);
        make.bottom.equalTo(self.view.mas_bottom).offset(0);
    }];
    
    self.collectView.emptyDataSetSource = self.collectView;
    self.collectView.emptyDataSetDelegate= self.collectView;
    
    __weak typeof(self) weakSelf = self;
    self.collectView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        [weakSelf loadData];
    }];
//    self.collectView.mj_footer=[MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
//        [weakSelf loadMoreRecommendData];
//    }];
    
    self.collectView.mj_footer=[MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
        [weakSelf loadMoreRecommendData];
    }];
    
    self.collectView.mj_footer.ignoredScrollViewContentInsetBottom = iPhoneXs ? 34 : 0;
    [self.collectView.mj_header beginRefreshing];
    
    self.collectView.mj_footer.hidden = YES;
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updataData) name:@"loginSuccessUpdataNotification" object:nil];//登录成功---刷新列表
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(scroVC) name:@"showLoginNotification" object:nil];//退出登录成功，列表有数据时滚动到第一个
//    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(daShanSuccess:) name:@"chatAccostSuccessNotification" object:nil];//搭讪成功
//    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(behaviorBlackSuccess:) name:@"CPBehaviorBlackNotification" object:nil];//用户详情页拉黑
   
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pushSJNotification) name:@"pushSJNotification" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showLogin:) name:@"showLoginNotification" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(chatingMessage:) name:@"chatingMessageNotification" object:nil];//收到聊天消息
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloData) name:@"foodCollcetNotification" object:nil];
    [self loaduser_account];
//    [self adolescent_modestatus];
    
//    [self loadOneLoginViewSX];
    
    self.arrayData = [PUFoodsModels.shared.list mutableCopy];
    
//    PUPerfectVC *vc=[[PUPerfectVC alloc]init];
//    [self.navigationController pushViewController:vc animated:YES];
}
-(void)reloData{
    [self.collectView reloadData];
}
//退出登录
-(void)showLogin:(NSNotification*)notification
{
    [self loadOneLoginViewSX];
}
-(void)loadOneLoginViewSX{
    
    
    PUPhoneLogin *vc=[[PUPhoneLogin alloc]init];
    UINavigationController *navVc = [[UINavigationController alloc] initWithRootViewController:vc];
    navVc.modalPresentationStyle=0;
    [self presentViewController:navVc animated:NO completion:nil];
}
-(void)pushSJNotification{
    
}
-(void)btnClick{
    
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];    
    [self.navigationController setNavigationBarHidden:YES animated:YES];
//    NSMutableArray *data=[NSMutableArray array];
//    data= [XLModel mj_objectArrayWithKeyValuesArray:[XLData taohuaData]];
//    NSLog(@"%@",data);
//    for (XLModel *model in data) {
//        NSLog(@"%@",model.flowers_name);
//    }
//
}

-(void)behaviorBlackSuccess:(NSNotification *)notification{
    
    NSString *user_id=notification.userInfo[@"user_id"];
    NSLog(@"成功:%@",user_id);
    
    int i=0;
    int ii=0;//获取到在第几个
    for (PUCityListModel *model in self.recommendData) {
        i++;
        if ([[NSString stringWithFormat:@"%d",model.ID] isEqualToString:user_id]) {
            ii=i-1;
            NSLog(@"%d",ii);
            PUHomeCell *cell = (PUHomeCell*)[self.collectView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:ii inSection:0]];
            NSIndexPath *indexPath=[self.collectView indexPathForCell:cell];
            [self.recommendData removeObjectAtIndex:ii];
            
            [self.collectView deleteItemsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil]];
            
            if (self.recommendData.count==0) {
                [self.collectView.mj_header beginRefreshing];
            }
            break;
        }
    }
}

-(void)daShanSuccess:(NSNotification *)notification{
    [self showSVProgressHUDStr:@"搭讪成功"];
    NSString *user_id=notification.userInfo[@"toUserId"];
    int i=0;
    int ii=0;//获取到在第几个
    for (PUCityListModel *model in self.recommendData) {
        i++;
        if ([[NSString stringWithFormat:@"%d",model.ID] isEqualToString:user_id]) {
//            model.chat_up=1;
            ii=i-1;
//            [self.collectView reloadItemsAtIndexPaths:@[[NSIndexPath indexPathForRow:ii inSection:0]]];
            
            PUHomeCell *cell = (PUHomeCell*)[self.collectView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:ii inSection:0]];
            cell.model.chat_up=1;
            NSIndexPath *indexPath=[self.collectView indexPathForCell:cell];
            [self.collectView reloadItemsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil]];
            break;
        }
    }
//    [self.collectView reloadData];
}

-(void)scroVC{
//    if (self.recommendData.count>0) {
//        [self.collectView scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UICollectionViewScrollPositionTop animated:NO];
//    }
}
-(void)updataData{
    [self loaduser_account];
//    self.isFirstLoad=0;
//    
//    //    if (self.cityListArray.count==0) {
//    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleDark];
//    [SVProgressHUD show ];
//    [SVProgressHUD showWithStatus:@"正在加载中，请稍后..."];
    [self loadData];
    //    }
    
}


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    PUFoodModel *model=self.taohuaData[indexPath.row];
    static NSString *identifier = @"XLHomeCell";
    PUHomeCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
    cell.delegate=self;
//    cell.model=model;
    cell.taohuaModel=model;
    [cell setCollectBlock:^{
        [collectionView reloadItemsAtIndexPaths:@[indexPath]];
    }];
    return cell;
    
}

-(void)noLogin{
    PUPhoneLogin *vc=[[PUPhoneLogin alloc]init];
    UINavigationController *navVc = [[UINavigationController alloc] initWithRootViewController:vc];
    navVc.modalPresentationStyle=0;
    [self presentViewController:navVc animated:NO completion:nil];
}

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView
           viewForSupplementaryElementOfKind:(NSString *)kind
                                 atIndexPath:(NSIndexPath *)indexPath {
    PUHomeReusableView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader
                                                                              withReuseIdentifier:@"CPHomeReusableView"
                                                                                     forIndexPath:indexPath];
    headerView.allData = self.arrayData;
    [headerView setMeunIndexBlock:^(NSInteger index) {
        PUCategoryVC *categoryVC = [[PUCategoryVC alloc]init];
        categoryVC.meunIndex = index;
        [self.navigationController pushViewController:categoryVC animated:true];
    }];
    [headerView setTopIndexBlock:^(PUFoodModel *model) {
        PUFoodDetailsVC *foodDetailsVC = [[PUFoodDetailsVC alloc]init];
        foodDetailsVC.model = model;
        [self.navigationController pushViewController:foodDetailsVC animated:true];
    }];
    return headerView;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.taohuaData.count;
}
- (CGFloat)minimumInteritemSpacing {
    return 0;
}
//定义每个UICollectionView 的大小
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake((collectionView.frame.size.width-30)/2,(collectionView.frame.size.width-30)/2*1.52);
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
    return  CGSizeMake(collectionView.frame.size.width, 515);
}

//计算有行距的文本的文本高度
-(CGFloat)getSpaceLabelHeight:(NSString *)str withAttrDict:(NSMutableDictionary *)dict withWidth:(CGFloat)width {
    CGSize size = [str boundingRectWithSize:CGSizeMake(width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:dict context:nil].size;
    return size.height;
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{
    return 10.0f;
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
{
    return 10.0f;
}

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
    return UIEdgeInsetsMake(10, 10, 10, 10);//分别为上、左、下、右
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    PUFoodModel *model=self.taohuaData[indexPath.row];
    PUFoodDetailsVC *vc=[[PUFoodDetailsVC alloc]init];
    vc.model=model;
    
    [self.navigationController pushViewController:vc animated:YES];
}

-(void)loadData{
    NSMutableArray *arrayData = [NSMutableArray array];
    for (PUFoodsModel *model in self.arrayData) {
        [arrayData addObjectsFromArray:model.foods];
    }
    self.taohuaData=[self getRandomArrFrome:arrayData];
    self.taohuaData2=self.taohuaData;
    self.page=1;
    [self loadRecommendData];
}

-(NSMutableArray*)getRandomArrFrome:(NSArray*)arr
{
    NSMutableArray *newArr = [NSMutableArray new];
    while (newArr.count != arr.count) {
        //生成随机数
        int x =arc4random() % arr.count;
        id obj = arr[x];
        if (![newArr containsObject:obj]) {
            [newArr addObject:obj];
        }
    }
    return newArr;
}

-(void)loadRecommendData{
    NSDictionary *param =@{
                            @"page":@"1",
                            @"birth":@"1",
//                            @"type":@(self.type)
                            @"type":@(0)
                           };
//    NSString *path=@"/user_recommend";
    NSString *path=@"/tourist/recommend";
    NSString *url1 = [NSString stringWithFormat:@"%@%@",baseUrl,path];
    [[AFNetManager shareManager] postDataWithURLString:url1 path:path parameters:param success:^(NSURLResponse *operation, id successObject) {
        [SVProgressHUD dismiss];
        NSString *result=successObject[@"result"];
        NSDictionary *dic=@{};
        if ([successObject[@"result"] isKindOfClass:[NSString class]]) {
            //解密Base64编码的字符串
            NSString *decryptedString = [AES128 decryptString:result key:dataKey iv:dataIv];
            dic=[AES128 dictionaryWithJsonString:decryptedString];
            NSLog(@"json解析===%@",dic);
        }
        
        if ([successObject[@"code"] integerValue] == 200) {
            self.recommendData= [PUCityListModel mj_objectArrayWithKeyValuesArray:dic[@"list"]];
            NSLog(@"%@",self.recommendData);
            NSMutableArray *array=[NSMutableArray array];

            for (int i=0; i<self.recommendData.count; i++) {
                if (i>=self.taohuaData.count) {
                    break;
                }
                PUFoodModel *model1=self.taohuaData[i];
                PUCityListModel *model2=self.recommendData[i];
                
                if (model1.userid == nil) {
                    model1.userid=[NSString stringWithFormat:@"%d",model2.ID];
                    model1.username=model2.nickname;
                    model1.userimage=model2.avatar;
                }
          
                [array addObject:model1];
            }
            
          
            self.taohuaData=array;
            if (self.recommendData.count >0) {
                self.collectView.mj_footer.hidden = NO;
            }
            if (self.taohuaData.count==16) {
                self.collectView.mj_footer.hidden = YES;
            }
        } else {
            [self showSVProgressHUDStr:successObject[@"message"]];
        }
        self.isFirstLoad=1;
        [self addEmptyData];
    } failure:^(NSError *error) {
        NSLog(@"错误：%@",error);
        [SVProgressHUD dismiss];
        if (self.recommendData.count == 0) {
            self.collectView.mj_footer.hidden = YES;
        }
        self.isFirstLoad=1;
        [self addEmptyData];
    }];
}
-(void)loadMoreRecommendData{
    NSDictionary *param =@{
                            @"page":[NSString stringWithFormat:@"%d",(int)++self.page],
                            @"birth":@"1",
//                            @"type":@(self.type)
                            @"type":@(0)
                           };
//    NSString *path=@"/user_recommend";
    NSString *path=@"/tourist/recommend";
    NSString *url1 = [NSString stringWithFormat:@"%@%@",baseUrl,path];
    [[AFNetManager shareManager] postDataWithURLString:url1 path:path parameters:param success:^(NSURLResponse *operation, id successObject) {
        
        NSString *result=successObject[@"result"];
        NSDictionary *dic=@{};
        if ([successObject[@"result"] isKindOfClass:[NSString class]]) {
            //解密Base64编码的字符串
            NSString *decryptedString = [AES128 decryptString:result key:dataKey iv:dataIv];
            dic=[AES128 dictionaryWithJsonString:decryptedString];
            NSLog(@"json解析===%@",dic);
        }
        
        if ([successObject[@"code"] integerValue] == 200) {
            
            NSArray *array = [PUCityListModel mj_objectArrayWithKeyValuesArray:dic[@"list"]];
            [self.recommendData addObjectsFromArray:array];
            
            NSMutableArray *array2=[NSMutableArray array];
            for (int i=0; i<self.recommendData.count; i++) {
                if (i>=self.taohuaData2.count) {
                    break;
                }
                PUFoodModel *model1=self.taohuaData2[i];
                PUCityListModel *model2=self.recommendData[i];
                if (model1.userid == nil) {
                    model1.userid=[NSString stringWithFormat:@"%d",model2.ID];
                    model1.username=model2.nickname;
                    model1.userimage=model2.avatar;
                }
                [array2 addObject:model1];

            }
           
            self.taohuaData=array2;
            if (array.count == 0) {
                self.collectView.mj_footer.hidden = YES;
            }
            if (self.taohuaData.count==16) {
                self.collectView.mj_footer.hidden = YES;
            }
        } else {
            [self showSVProgressHUDStr:successObject[@"message"]];
        }
        [self.collectView.mj_footer endRefreshing];
        [self.collectView reloadData];
       
    } failure:^(NSError *error) {
        NSLog(@"错误：%@",error);
        [self.collectView.mj_footer endRefreshing];
    }];
}

-(void)addEmptyData{
    [self.collectView.mj_header endRefreshing];
  
    self.collectView.configuer.emptyType =  ( self.recommendData.count == 0) ? DznEmptyDataTypeSuccess : DznEmptyDataTypeDefault;
//        self.tableView.configuer.emptyType =  DznEmptyDataTypeSuccess;
    [self.collectView reloadData];
}

-(void)showSVProgressHUDStr:(NSString *)str{
    if ([str isKindOfClass:[NSNull class]]||str==nil||[str isEqualToString:@""]) {
        return;
    }
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleDark];
    [SVProgressHUD showImage:[UIImage imageNamed:@""] status:str];
}
/**
 响应链的方法
 */
- (UIViewController *)viewController {
    for (UIView* next = [self.view superview]; next; next = next.superview) {
        UIResponder *nextResponder = [next nextResponder];
        if ([nextResponder isKindOfClass:[UIViewController class]]) {
            return (UIViewController *)nextResponder;
        }
    }
    return nil;
}

//加载归档的数据
-(void)loadArchiveData{
    NSMutableArray *data=[NSMutableArray array];
    NSString *library=NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES)[0];
    NSString *strLib = [library stringByAppendingPathComponent:@"archive"];
    BOOL directory = YES;
    if (![[NSFileManager defaultManager] fileExistsAtPath:strLib isDirectory:&directory]){
        [[NSFileManager defaultManager] createDirectoryAtPath:strLib withIntermediateDirectories:NO attributes:nil error:nil];
    }
    //从归档中读出
    NSString *arrayArchive =[strLib stringByAppendingPathComponent:[NSString stringWithFormat:@"circleDataArchive%@",@"123"]];//用首页唯一标示id创建文件名
    NSArray *categoryAry = [NSKeyedUnarchiver unarchiveObjectWithFile:arrayArchive];
    if (categoryAry&&[categoryAry count])
    {
        data=[NSMutableArray arrayWithArray:categoryAry];
    }
    else
    {
//        [self getRequest];//get请求界面
    }
    
   
}

-(void)save{
    NSMutableArray *data=[NSMutableArray array];
    //创建一个归档文件夹
    NSArray *library = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
    NSString *strLib = [[library objectAtIndex:0] stringByAppendingPathComponent:@"archive"];
    BOOL directory = YES;
    if (![[NSFileManager defaultManager] fileExistsAtPath:strLib isDirectory:&directory])
    {
        [[NSFileManager defaultManager] createDirectoryAtPath:strLib withIntermediateDirectories:NO attributes:nil error:nil];
    }
    //归档
    NSString *entityArchive = [strLib stringByAppendingPathComponent:[NSString stringWithFormat:@"circleDataArchive%@",@"123"]];
    [NSKeyedArchiver archiveRootObject:data toFile:entityArchive];
    //数据源从归档中读出
    NSMutableArray *array = [NSKeyedUnarchiver unarchiveObjectWithFile:entityArchive];
    NSLog(@"%@",array);
}

-(void)loaduser_account{
    return;
    NSDictionary *param =@{
                            
                           };
    NSString *path=@"/user_account";
    NSString *url1 = [NSString stringWithFormat:@"%@%@",baseUrl,path];
    [[AFNetManager shareManager] postDataWithURLString:url1 path:path parameters:param success:^(NSURLResponse *operation, id successObject) {
        
        NSString *result=successObject[@"result"];
        NSDictionary *dic=@{};
        if ([successObject[@"result"] isKindOfClass:[NSString class]]) {
            //解密Base64编码的字符串
            NSString *decryptedString = [AES128 decryptString:result key:dataKey iv:dataIv];
            dic=[AES128 dictionaryWithJsonString:decryptedString];
            NSLog(@"json解析===%@",dic);
        }
        
        if ([successObject[@"code"] integerValue] == 200) {
            NSString *coin = [NSString stringWithFormat:@"%@",dic[@"coin"]];
            NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
            NSString *coin2 = [userDefaults objectForKey:[NSString stringWithFormat:@"coin_%@",[Config getID]]];
            if ([coin2 isEqualToString:@""]||coin2==NULL||coin2==nil||[coin2 isEqualToString:@"0"]){
                [userDefaults setObject:coin forKey:[NSString stringWithFormat:@"coin_%@",[Config getID]]];
                [userDefaults synchronize];
            }
           
        } else {
            [self showSVProgressHUDStr:successObject[@"message"]];
        }
        
    } failure:^(NSError *error) {
        NSLog(@"错误：%@",error);
    }];
}

//收到聊天消息
-(void)chatingMessage:(NSNotification *)notification{
    NSDictionary *body=notification.userInfo[@"message"];
    NSLog(@"%@",body);
    
    if([body[@"type"] isEqualToString:@"send_message"]){//普通消息
        NSLog(@"111111");
    }else if([body[@"type"] isEqualToString:@"send_system_notify"]){//发送系统通知
        
    }else if([body[@"type"] isEqualToString:@"send_dynamic_notify"]){//动态通知------暂未用到
        
    }else if([body[@"type"] isEqualToString:@"tv_notify_signal"]){//动态通知------暂未用到
        
    }else if([body[@"type"] isEqualToString:@"intimacy_upgrade_signal"]){//倾诉值变更信号
        
    }else if([body[@"type"] isEqualToString:@"charm_level_up_signal"]){//魅力值升级信号------暂未用到
        
    }else if([body[@"type"] isEqualToString:@"wealth_level_up_signal"]){//财富值升级信号------暂未用到
        
    }else if([body[@"type"] isEqualToString:@"grab_chat_match_signal"]){//速配信号------暂不开发
        
    }else if([body[@"type"] isEqualToString:@"grab_chat_call_answer_signal"]){//速配通话接听信号------暂不开发
        
    }else if([body[@"type"] isEqualToString:@"video_popup_signal"]){//速配视频弹窗信号------暂不开发
        
    }else if([body[@"type"] isEqualToString:@"task_finish_signal"]){//任务完成，弹出任务完成弹窗
        
    }else if([body[@"type"] isEqualToString:@"system_award_signal"]){//系统奖励信号
        
    }else if([body[@"type"] isEqualToString:@"call_calling_signal"]){//通话呼叫信号---------收到通话呼叫 打开通话被呼叫界面
        
    }else if([body[@"type"] isEqualToString:@"invite_call_calling_signal"]){//邀请通话呼叫信号--------收到通话邀请 打开通话被邀请界面
        
    }else if([body[@"type"] isEqualToString:@"call_cancel_signal"]){//通话被取消信号--------通话接听之前被取消 关闭通话接听界面
        
    }else if([body[@"type"] isEqualToString:@"call_cancel_signal"]){//通话被拒绝信号--------通话被拒绝接听 关闭通话拨打界面  data字段说明: 同通话被取消信号
        
    }else if([body[@"type"] isEqualToString:@"call_answer_signal"]){//通话被接听信号--------通话被接听 处理通话接通界面
        
    }else if([body[@"type"] isEqualToString:@"call_hangup_signal"]){//通话挂断信号--------通话中被对方手动挂断 关闭通话界面
        
    }else if([body[@"type"] isEqualToString:@"call_system_hangup_signal"]){//通话系统挂断信号--------话中被系统挂断 关闭通话界面  同通话挂断信号
        
    }else if([body[@"type"] isEqualToString:@"call_time_reset"]){//通话时间同步信号--------同步通话中的通话时间
        
    }else if([body[@"type"] isEqualToString:@"call_signal_try_close"]){//通话未露脸关闭提示信号--------通话中对方长时间未露脸提示，提示用户是否需要关闭通话
        
    }else if([body[@"type"] isEqualToString:@"call_coin_not_enough_remind_signal"]){//通话中金币不足信号--------通话中，金币不足时弹出提示，并引导去充值
        
    }else if([body[@"type"] isEqualToString:@"call_violation_remind_signal"]){//通话违规提醒信号--------通话中被检测到有违规行为，弹出提示警告用户
        
    }else if([body[@"type"] isEqualToString:@"version_upgrade"]){//版本升级信号--------有新版本可升级信息，弹出升级弹窗
        
    }else if([body[@"type"] isEqualToString:@"user_change_signal"]){//用户变更信号--------去更新用户相关信息 这里跟send_system_notify一样的处理流程
        
        NSDictionary *data=body[@"data"];
        NSDictionary *data2=data[@"data"];
        int type=[data[@"type"]intValue];
        if (type==1) {
            NSString *black_status=[NSString stringWithFormat:@"%@",data2[@"black_status"]];
            LiveUser *user = [[LiveUser alloc] init];
            user.black_status = black_status;
            [Config updateProfile:user];
        }
       
    }else if([body[@"type"] isEqualToString:@"online_notice"]){//上线通知--------暂未使用
        
    }else if([body[@"type"] isEqualToString:@"message_send_fail_signal"]){//消息发送失败信号--------消息发送失败信号，删除对应服务器id消息，并处理错误码
        
    }else if([body[@"type"] isEqualToString:@"trigger_try_chat_signal"]){//试聊触发信号--------暂不开发
        
    }else if([body[@"type"] isEqualToString:@"treasury_remind"]){//福利池达标提醒--------暂不开发
        
    }else if([body[@"type"] isEqualToString:@"gift_update_signal"]){//礼物数据更新--------重新请求某些数据并更新
        
    }else if([body[@"type"] isEqualToString:@"common_remind"]){//通用弹窗提醒--------弹出通用提示跳转弹出（标题+内容+我知道了按钮+跳转按钮）
        
    }else if([body[@"type"] isEqualToString:@"daily_wiring"]){//每日牵线弹窗--------弹出每日牵线弹出
        
    }else if([body[@"type"] isEqualToString:@"appo_rank_notice_push"]){//速配通知--------暂不开发
        
    }else if([body[@"type"] isEqualToString:@"active_notice_push_signal"]){//活动通知弹窗--------弹出活动轮播图
        
    }else if([body[@"type"] isEqualToString:@"information_remind"]){//资料补充提醒-------- 弹出弹窗提醒用户去完善资料
        
    }else if([body[@"type"] isEqualToString:@"user_online_notice"]){//订阅用户上线通知-------- 自己上线后 会收到此通知 自己需要发消息通知订阅自己的切在线的用户自己上线了
        
    }else if([body[@"type"] isEqualToString:@"system_black_status"]){//系统黑名单状态变更信号-------- 更新自己的系统黑名单状态 用户信息里的`black_status`字段名
      
    }else if([body[@"type"] isEqualToString:@"male_reply_active_signal"]){//男用户回复奖励活动信号-------- 更新回复某个女用户可获奖励过期时间(搭配用户聊天框信息使用) 如果type为2且award不为空，则同系统奖励信号一样弹出系统奖励弹窗
        
    }else if([body[@"type"] isEqualToString:@"video_flip_push_signal"]){//男用户收到视频翻牌活动信号--------暂不开发
        
    }else if([body[@"type"] isEqualToString:@"video_flip_match_signal"]){//女用户收到视频翻盘信号--------暂不开发
        
    }else if([body[@"type"] isEqualToString:@"video_flip_answer_signal"]){//男用户收到视频翻盘接听信号--------暂不开发
        
    }
}

-(void)adolescent_modestatus{
    
//    NSDictionary *param =@{
//                          
//                           };
//    NSString *path=@"/adolescent_mode/status";
//    NSString *url1 = [NSString stringWithFormat:@"%@%@",baseUrl,path];
//    [[AFNetManager shareManager] postDataWithURLString:url1 path:path parameters:param success:^(NSURLResponse *operation, id successObject) {
//        
//        NSString *result=successObject[@"result"];
//        NSDictionary *dic=@{};
//        if ([successObject[@"result"] isKindOfClass:[NSString class]]) {
//            //解密Base64编码的字符串
//            NSString *decryptedString = [AES128 decryptString:result key:dataKey iv:dataIv];
//            dic=[AES128 dictionaryWithJsonString:decryptedString];
//            NSLog(@"json解析===%@",dic);
//        }
//        
//        if ([successObject[@"code"] integerValue] == 200) {
//            int status=[dic[@"status"] intValue];
//            if (status==1) {
//                CPQSNMSVC *vc=[[CPQSNMSVC alloc]init];
//                [self.navigationController pushViewController:vc animated:NO];
//            }
//        } else {
////            [self showSVProgressHUDStr:successObject[@"message"]];
//        }
//        
//    } failure:^(NSError *error) {
//        NSLog(@"错误：%@",error);
//    }];
}

@end

